#
# Classifier for messages from Bigfoot
# This also handles some Yahoo addresses...
#
package Mail::Bounce::Bigfoot;
use strict;
use vars qw(@ISA $pattern $pattern2);

#$Mail::Bounce::Heuristic::DEBUG = 1;

@ISA = qw(Mail::Bounce::Heuristic);

$pattern = << 'EoF';
The message you tried to send to <${RECIP-\S+}>
was not deliverable.


${DIAG-(?s:.*)}


The first 100 lines of the original message...
EoF

$pattern2 = << 'EoF';
This pattern is not used yet.
EoF

sub validate {
    my $self = shift;

    my $keywords = $self->patternmatch($self->bodyhandle->as_string, $pattern);
    return defined($keywords);
}

sub recipients {
    my $self = shift;

    my $keywords = $self->patternmatch($self->bodyhandle->as_string, $pattern);
    if (defined($keywords)) {
	if (wantarray()) {
	    my $res = new Mail::Bounce::Address;
	    $res->action("failed");
	    my $diag = $$keywords{DIAG};
	    if ($diag =~ /The mailbox on recipient\'s host is not available./) {
		$res->type("permfail");
                $res->status("5.1.1 (Mailbox not available)");
	    } elsif ($diag =~ /You may try again/) {
		$res->type("tempfail");
		if ($diag =~ /Exceeded storage allocation/) {
		    $res->status("4.2.2 (Mailbox full)");
		} else {
		    $res->statsu("4.0.0");
		}
	    }
	    $diag =~ s/\n/ /g;
	    $res->diagnostic("Bigfoot; $diag");
	    $res->final_recipient($$keywords{RECIP});
	    return $res;
	} else {
	    return 1;
	}
    } else {
	die "Bigfoot: Unmatched pattern in recipients()\n";
    }
}
1;




